<template>
  <view class="lock-screen-controls" v-if="visible">
    <image class="album-cover" :src="currentSong.cover || '/static/logo.png'"></image>
    <view class="song-info">
      <text class="title">{{ currentSong.title }}</text>
      <text class="artist">{{ currentSong.artist || '未知歌手' }}</text>
    </view>
    <view class="controls">
      <button @tap="$emit('play-prev')" class="control-btn">◄◄</button>
      <button @tap="onTogglePlay" class="control-btn">
        {{ isPlaying ? '❚❚' : '►' }}
      </button>
      <button @tap="$emit('play-next')" class="control-btn">►►</button>
    </view>
    <slider class="progress-bar" 
            :value="currentTime" 
            :max="duration" 
            @change="onSeek"
            block-size="12"
            activeColor="#FF0000"/>
    <view class="time-display">
      <text>{{ formatTime(currentTime) }}</text>
      <text>{{ formatTime(duration) }}</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    visible: Boolean,
    currentSong: Object,
    isPlaying: Boolean,
    currentTime: Number,
    duration: Number
  },
  methods: {
    formatTime(seconds) {
      const mins = Math.floor(seconds / 60);
      const secs = Math.floor(seconds % 60);
      return `${mins}:${secs < 10 ? '0' : ''}${secs}`;
    },
    onTogglePlay() {
      this.$emit('toggle-play');
    },
    onPrev() {
      this.$emit('play-prev');
    },
    onNext() {
      this.$emit('play-next');
    },
    onSeek(e) {
      this.$emit('seek', e.detail.value);
    }
  }
}
</script>

<style>
.lock-screen-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 40rpx;
}

.album-cover {
  width: 300rpx;
  height: 300rpx;
  border-radius: 20rpx;
  margin-bottom: 40rpx;
}

.song-info {
  margin-bottom: 40rpx;
  text-align: center;
}

.title {
  font-size: 36rpx;
  color: #FFFFFF;
  margin-bottom: 10rpx;
  display: block;
}

.artist {
  font-size: 28rpx;
  color: #AAAAAA;
  display: block;
}

.controls {
  display: flex;
  justify-content: center;
  margin-bottom: 40rpx;
  width: 100%;
}

.control-btn {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 80rpx;
  height: 80rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 40rpx;
  color: white;
  font-size: 40rpx;
}

.control-btn:active {
  background: rgba(255, 255, 255, 0.4);
}

.progress-bar {
  width: 100%;
  margin-bottom: 20rpx;
}

.time-display {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: #AAAAAA;
  font-size: 24rpx;
}
</style>